using System.Collections.Generic;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.HealthChecks;

namespace Agile.HealthChecks {
    public class HealthChecksStartup : IAgileStartup
    {
        public int Order => 7000;

        public void Configure(IApplicationBuilder app)
        {

        }

        public void ConfigureMvc(MvcOptions mvcOptions)
        {

        }

        public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
        {
            services.AddHealthChecks(checks => {
                checks.AddPrivateMemorySizeCheck(1);
                checks.AddVirtualMemorySizeCheck(2);
                checks.AddWorkingSetCheck(1);
                checks.AddUrlChecks(new List<string> { "https://www.cnblogs.com", "https://www.baidu.com", "https://www.csdn.net" }, "servers");
                checks.AddDbCheck();
                checks.AddEnvironmentCheck();
                checks.AddGcCheck();
                checks.AddMemoryCheck();
                checks.AddNetCoreRuntimeCheck();
            });
        }
    }
}
